User blog:Sadowson/Dungeon Siege's incredibly complicated and incredibly simple mapping
Dungeon Siege (And it's successor Dungeon Siege II to a more advanced degree) utilizes as system for it's mapping which is totally unique from other games in that it's logical positioning system is largely non-existent. (Note: Grab a coffee - newcomers will probably need to read this twice or three times) A question was asked recently as to how Dungeon Siege is able to have it's maps overlay each other yet not glitch both visually and mechanically. This is both really complicated in the larger scale of things, and really simple in the smaller sense. First and foremost, DS breaks it's map down in the following format: *Map (The entire map that you play in) *Region (Which is a segment of the map. Stonebridge (Map_World: bt_r1) and Elddim (Multiplayer World: town_center) are prime examples of this *Nodes (These are individual tile pieces that make up a region. Like a dungeon for example.) The easiest way to understand how this whole thing fits together is to work from the ground upwards. I'll explain it as best as I can. Nodes Nodes form the individual tiles that make up a region. They are connected via "doors" (AKA the sides of the tile piece) to the "doors" on other nodes. Two 4x4 flat squares make a 4x8 terrain segment. A "wall" can then be added to make a world barrier. Walls can consist of anything, from a dungeon's brick walls to a rocky cliff. Dungeon Siege doesn't discriminate on the appearance. There are, obviously, traversers for walls in the form of staircases and dirt ramps. Throw a thousand other pieces in there and suddenly you have a large dungeon ready for skeletal beings, a narrow valley filled with bandits, or a thriving community of farmers and merchants. The only requirement for two doors to connect to each other is that they must be of equal size and shape. For example, you can't connect a the wall of a waterfall to a dungeon archway. Not only will it look stupid, DS will complain about logic and mathematical issues. (Though it might still work... somehow) Regions Overview A group of nodes, regardless of how big or small, is then listed under a single region. The reasons for this are twofold: *It vastly reduces the processor requirement for editing a map. Editing just the area around Stonebridge is far more efficient if your computer isn't loading terrain as far away as Fortress Kroth. *Localization of object positioning. This will be explained further down. Regions can be anything - dungeons, towns, forts, forests - whatever. Think of it in the same method as looking at a real world map. Washington DC would be it's own region and the forests and farms surrounding it would be their own seperate regions. The theoretical limit to the number of regions in a world is directly correllated with the number of objects in your world. But this is really complicated mathematical mumbo jumbo that would require it's own seperate blog post. But here is where Dungeon Siege differs from other games. Skyrim is a prime example of modern day mechanics with mapping. When your on the overworld (AKA, outside), the game loads the entire map, but has very low resolution for terrain very far away, and objects are only loaded within a certain radius. Dungeon Siege works completely differently. Objects AND terrain is only loaded USUALLY up to 50m away from the player - not the entire game world. This means that - for example - while you are in Elddim, there is literally nothing for Crystwind loaded in system memory - at all. For example, take a completely straight canyon of grass with two walls on either side. As the player moves forward along the canyon, the terrain nodes in front of them is loaded, and the terrain behind them is unloaded. If the player turns around, the loading still works the same. Whatever direction they move in, the terrain in front is loaded, behind them unloaded, etc etc etc. Stitching In order to connect regions together (Like Elddim to Elddim Lowlands), DS uses a method called "stitching", which is basically lining up nodes from one map to another, assigning an ID and region for connection, and then having them load side by side when the player approaches. Dungeon Siege links and loads the nodes up in the game, NOT in the editor. This means the player can progress from Elddim all the way to the crypt and beyond. Localized Object Positioning Alright, so this is where things get REALLY complex. Virtually all games position their objects on a GLOBAL 3D axis. Dungeon Siege doesnt. It positions things on a LOCALIZED position relative to the centre of the region (Note: The center is where the FIRST node is placed - NOT the target node - that's a thing for editors, nothing you need to worry about in this description) The exact same applies for players. Their relative position is handled by region they occupy, not the global position. When they move from one region to another, their position is updated for the new region occupation. It's why Dungeon Sieges AI path finding mechanics can sometimes be a little bit wonky. Breaking of RL physics Because of the above method of region loading, this means that you can theoretically have a map that circles back on itself - even if logically it shouldn't be able to. Dungeon Siege literally does not care if something lines up. Due to a lack of global positioning and instead relying on local positioning and stitching, you can have regions that literally go through each other. But you won't see the other region because it's not loaded relative to the region you are in now. A prime example of this is with the multiplayer map, the Utraean Peninsula, where the maps very - very - often overlap each other and yet you won't see the offending regions due to the nature of the game engine. It's both a curse and a blessing at the same time. Map Well this is freaking simple. A map defines all of the regions collectively under one file. Give it a name, a shiny description and boombadabing, that's it. Conclusion I hope this helps people understand a little bit more about how this all works. If you have any questions, fire away. I've learned this mostly through official tutorials + documentation as well as my own tinkering. Category:Blog posts